
function TestDbPwd()
{

    var dbHost = $('#dbhost').val();
    var dbUser = $('#dbuser').val();
    var dbPwd = $('#dbpw').val();
    var dbName = $('#dbname').val();
    var dbPort = $('#dbport').val();
    data = {'dbHost': dbHost, 'dbUser': dbUser, 'dbPwd': dbPwd, 'dbName': dbName, 'dbPort': dbPort};
//    console.log(data)
    var url = "./index?step=3&testdbpwd=1";
    $.ajax({
        type: "POST",
        url: url,
        data: data,
        beforeSend: function() {
        },
        success: function(msg) {
//           console.log(typeof(msg));
//           console.log(msg);
            if (msg.replace(/\s/g, "")==='1') {

            } else {
//                alert()
                $('#dbpw').val("");
                $('#J_install_tip_dbpw').html('<span for="dbname" generated="true" class="tips_error" style="">数据库链接配置失败</span>');
            }
        },
        complete: function() {
        },
        error: function() {
            $('#J_install_tip_dbpw').html('<span for="dbname" generated="true" class="tips_error" style="">数据库链接配置失败</span>');
            $('#dbpw').val("");
        }
    });
}
$(function() {

    //聚焦时默认提示
    var focus_tips = {
        dbhost: '数据库服务器地址，一般为localhost',
        dbport: '数据库服务器端口，一般为3306',
        dbuser: '',
        dbpw: '',
        dbname: '',
        dbprefix: '建议使用默认，同一数据库安装多个时需修改',
        manager_email: '创始人帐号，拥有站点后台所有管理权限',
        manager_pwd: '',
        manager_ckpwd: '',
    };


    var install_form = $("#J_install_form"),
            reg_username = $('#J_reg_username'), //用户名表单
            reg_password = $('#J_reg_password'), //密码表单
            reg_tip_password = $('#J_reg_tip_password'), //密码提示区
            response_tips = $('#J_response_tips');				//后端返回提示

    //validate插件修改了remote ajax验证返回的response处理方式；增加密码强度提示 passwordRank
    install_form.validate({
        //debug : true,
        //onsubmit : false,
        errorPlacement: function(error, element) {
            //错误提示容器
            $('#J_install_tip_' + element[0].name).html(error);
        },
        errorElement: 'span',
        //invalidHandler : , 未验证通过 回调
        //ignore : '.ignore' 忽略验证
        //onkeyup : true,
        errorClass: 'tips_error',
        validClass: 'tips_error',
        onkeyup: false,
        focusInvalid: false,
        rules: {
            dbhost: {
                required: true
            },
            dbport: {
                required: true
            },
            dbuser: {
                required: true
            },
            /*dbpw: {
             required	: true
             },*/
            dbname: {
                required: true
            },
            dbprefix: {
                required: true
            },
            manager_email: {
                required: true
            },
            manager_pwd: {
                required: true
            },
            manager_ckpwd: {
                required: true,
                equalTo: '#J_manager_pwd'
            }
        },
        highlight: false,
        unhighlight: function(element, errorClass, validClass) {
            var tip_elem = $('#J_install_tip_' + element.name);

            tip_elem.html('<span class="' + validClass + '" data-text="text"><span>');

        },
        onfocusin: function(element) {
            var name = element.name;
            $('#J_install_tip_' + name).html('<span data-text="text">' + focus_tips[name] + '</span>');
            $(element).parents('tr').addClass('current');
        },
        onfocusout: function(element) {
            var _this = this;
            $(element).parents('tr').removeClass('current');

            if (element.name === 'email') {
                //邮箱匹配点击后，延时处理
                setTimeout(function() {
                    _this.element(element);
                }, 150);
            } else {

                _this.element(element);

            }

        },
        messages: {
            dbhost: {
                required: '数据库服务器地址不能为空'
            },
            dbport: {
                required: '数据库服务器端口不能为空'
            },
            dbuser: {
                required: '数据库用户名不能为空'
            },
            dbpw: {
                required: '数据库密码不能为空'
            },
            dbname: {
                required: '数据库名不能为空'
            },
            dbprefix: {
                required: '数据库表前缀不能为空'
            },
            manager_email: {
                required: '管理员帐号不能为空'
            },
            manager_pwd: {
                required: '密码不能为空'
            },
            manager_ckpwd: {
                required: '重复密码不能为空',
                equalTo: '两次输入的密码不一致。请重新输入'
            }
        },
        submitHandler: function(form) {
            form.submit();
            return true;
        }
    });


    var _data = {};
});